/**
  ******************************************************************************
  * @file           : main.c
  * @brief          : Main program body
  ******************************************************************************
  * @attention
  *
  */

/* Includes ------------------------------------------------------------------*/
#include <stdio.h>
#include "stdarg.h"
#include "board.h"
#include "systick.h"
#include "main.h"
#include "foc.h"

int main(void)
{
    //for debug mode
    do
    {
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_DBG, ENABLE);
        DBGMCU_APB2PeriphConfig(DBGMCU_TIM1_STOP, ENABLE);
    }
    while (0);
	
    FWREG_ParameterInit();
	
    Systick_Init(SystemCoreClock / 1000);
    Bsp_Gpio_Init();
	
    Peripheral_Init();
    //ParameterInit();

#if(P_FG_FUNC_EN)
    FG_Init();
#endif
	
#if(P_CONTROL_MODE == P_CONTROL_DUTY)
    Capture_Init();
#endif
	
#if(P_DEBUG_RTT_EN)
    SEGGER_RTT_ConfigUpBuffer(1, "JScope_u2i2i2i2", bRttBuf, 128, SEGGER_RTT_MODE_NO_BLOCK_SKIP);
#endif

    while (1)
    {
        IWDG_ReloadCounter();
        TaskScheduler();
		
		printf("{phase_current:%f,%f,%f} \n", Ta, Tb, Tc);	 
    }
}


